package presentation;

import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Image;
import java.awt.RenderingHints;
import java.awt.Shape;
import java.awt.font.FontRenderContext;
import java.awt.geom.GeneralPath;
import java.io.File;
import java.io.IOException;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedHashMap;

import javax.imageio.ImageIO;
import javax.swing.JPanel;

import control.CControl;


public class PBatteryPackImage extends JPanel{

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	
	private final Double IMAGE_WIDTH = 858., IMAGE_HEIGHT= 470.;
	
	private Image batImage = null;

	public PBatteryPackImage(CControl cControl) 
	{

		setBackground(Color.white);
		
		
	
	}
	
	protected void paintComponent(Graphics g) {
    	super.paintComponent(g);
    	Graphics2D g2 = (Graphics2D)g;
    	g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, 
    			RenderingHints.VALUE_ANTIALIAS_ON);
    	
    	
    	g2.setStroke(new BasicStroke(5));
    	
    	drawBACoutline(g2);
    	
    	int[] nr = new int[4];
    	nr[0] = 1;
    	nr[1] = 2;
    	nr[2] = 5;
    	nr[3] = 6;
    	
    	int i;
    	for(i=0;i<4;i++)
    	{
    		drawBatteryContainer(g2, String.format("Bank %d",nr[i]), 30+i*65, 15);
    	}
    	
    	for(i=0;i<2;i++)
    	{
    		drawBatteryContainer(g2, String.format("Bank %d",i+3), 65+30+i*65, 80);
    	}
    	
	}
	
	void drawBatteryContainer(Graphics2D g2, String name,int offset_x,int offset_y)
	{
		g2.setColor(Color.blue);
		g2.fillRect(offset_x, offset_y, 60, 60);
		g2.setColor(Color.white);
		g2.drawString(name, offset_x+5, offset_y+30);
	
	}
	
	void drawBACoutline(Graphics2D g2)
	{
		
    	// pack outline
    	GeneralPath p = new GeneralPath();
    	
    	int sx,sy;
    	sx = sy = 10;
    	p.moveTo(sx, sy);
    	p.lineTo(0+sx, 100+sy);
    	p.lineTo(100+sx, 200+sy);
    	p.lineTo(200+sx, 200+sy);
    	p.lineTo(300+sx, 100+sy);
    	p.lineTo(300+sx,0+sy);
    	p.closePath();
    	
    	g2.draw(p);
		
	}
}

